<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Document_model extends MY_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    public function getMyDocumentList($fields = ' * ',$per_page, $limit, $filter)
    {
    	$where = " ";
        if($filter['departmentid']){
            $where .= " AND departmentid = {$filter['departmentid']}";
        }
    	$limit = " limit {$per_page},{$limit}";

        $sql = "SELECT {$fields} FROM tr_document WHERE isDel=0 {$where}  ORDER BY addtime DESC {$limit} ";

        $query = $this->db->query($sql);
        $result =$query->result_array();
        return $result;
    }


    public function getMyDocumentListCnt($filter)
    {
        $where = " ";
        if($filter['departmentid']){
            $where .= " AND departmentid = {$filter['departmentid']}";
        }
        $sql = "SELECT id FROM tr_document WHERE isDel=0 {$where} ORDER BY addtime DESC";
        $query = $this->db->query($sql);
        return $query->num_rows();
    }
    public function get_cat_list(){
        $this->db->order_by("sort","desc");
        $query = $this->db->get("tr_department");
        return $query->result_array();
    }
    
}

/* End of file Document_model.php */
/* Location: ./application/models/document_model.php */